
#include <BFont>
#include <BWidget>
#include <BMenuBar>

#include "member_BMenuBar.h"

using namespace BWE;

member_BMenuBar::member_BMenuBar()
{
	space = 1;
	align = Align_Center;
	hoverIndex = -1;
	pressed = false;
}
member_BMenuBar::~member_BMenuBar()
{

}

void member_BMenuBar::adjustMenuRects(BMenuBar* boss)
{
	const BFont* font = boss->font();
	if (!font)
		return;

	BRect clientRect = boss->clientRect();
	int ch = clientRect.height();
	int cw = clientRect.width();

	int posX = clientRect.left() + space;
	int posY = clientRect.top();
	for (int i = 0; i < menus.size(); i++)
	{
		const BString& title = menus[i].menu->name();
		BSize textSize = font->textSize(title);
		BRect rect(posX, posY, textSize.width(), ch);

		menus[i].rect = rect.align(align, textSize);
		posX += textSize.width() + space;
	}
}
